﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lidgren.Network;
using Model.LiveControl;

namespace Network.Messages.LiveControl.S2C
{
    public class S2CResponseShareFormListMessage : NovaMessage
    {
        public FormItemModel[] FormItemModels;
        public S2CResponseShareFormListMessage() : base((ushort)CustomMessageType.S2CResponseShareFormListMessage)
        {
        }

        public override void WritePayload(NetOutgoingMessage message)
        {
            base.WritePayload(message);
            message.Write(FormItemModels.Length);
            foreach (var formItemModel in FormItemModels)
            {
                formItemModel.WritePayload(message);
            }
        }

        public override void ReadPayload(NetIncomingMessage message)
        {
            base.ReadPayload(message);
            int length = message.ReadInt32();
            FormItemModels  = new FormItemModel[length];
            for (int i = 0; i < length; i++)
            {
                FormItemModels[i].ReadPayload(message);
            }
        }
    }
}
